/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.demo.gpio.led;

import com.pi4j.context.Context;
import info.peigen.hotpot.demo.gpio.Application;
import info.peigen.hotpot.demo.gpio.Pin;


/**
 * <b>(RaspberryPiLed)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/2/13
 */
public class RaspberryPiLed implements Application {
    @Override
    public void execute(Context pi4j) {
        System.out.println("Simple LED app started ...");

        // Create a new SimpleLED component
        SimpleLed led = new SimpleLed(pi4j, Pin.D26);

        // Turn on the LED to have a defined state
        System.out.println("Turn on LED.");
        led.on();
        delay(1000);

        // Make a flashing light by toggling the LED every second
        for (int i = 0; i < 10; i++) {
            System.out.println("Current LED state is " + led.toggleState() + ".");
            delay(1000);
        }

        // That's all so turn off the relay and quit
        led.off();
        System.out.println("Turn off LED.");
        delay(2000);

        System.out.println("Simple LED app done.");
    }
}
